package com.tenda.sonicdemo;

import android.os.Bundle;
import android.webkit.WebView;

import com.tencent.sonic.sdk.SonicSessionClient;

import java.util.HashMap;

/**
 * Created by DongHao on 2017/8/16.
 * Description:
 */

public class MySonicSessionClientImpl extends SonicSessionClient {
    private WebView mWebView;

    public void bindWebView(WebView webView) {
        mWebView = webView;
    }

    public WebView getWebView() {
        return mWebView;
    }

    @Override
    public void loadUrl(String url, Bundle extraData) {
        mWebView.loadUrl(url);
    }

    @Override
    public void loadDataWithBaseUrl(String baseUrl, String data, String mimeType, String encoding, String historyUrl) {
        mWebView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
    }

    @Override
    public void loadDataWithBaseUrlAndHeader(String baseUrl, String data, String mimeType, String encoding, String historyUrl, HashMap<String, String> headers) {
        loadDataWithBaseUrl(baseUrl, data, mimeType, encoding, historyUrl);
    }

    public void destory() {
        if (mWebView != null) {
            mWebView.destroy();
            mWebView = null;
        }
    }
}
